package com.wx.exam.controller;
import com.wx.exam.dao.UserMapper;
import com.wx.exam.pojo.User;
import com.wx.exam.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @Author ychiha
 * @Date 2021/11/22 15:53
 * @Version 1.0
 */
@RestController //自动转换为json数据
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 返回用户id (前端的openid)
     * @return
     */
    @RequestMapping("/uidlist")
    public List uidlist(){
        List<String> uidList = userService.getUidList();
        System.out.println(uidList);
        return uidList;
    }

    /**
     * 返回前端 用户 列表
     * @return
     */
    @RequestMapping("/userlist")
    public List userlist(){
        List<User> list = userService.getUserList();
        return list;
    }

    /**
     * 添加用户信息
     * @param user
     * @return
     */
    @PostMapping("/adduser")
    public Boolean addUser(@RequestBody User user){
        System.out.println(user);
        return userService.addUser(user);
    }

    /**
     * 更改背景图片
     * @param user
     * @return
     */
    @PostMapping("/update/background")
    public Boolean updateBackground(@RequestBody User user){
        System.out.println("=============================================================");
        System.out.println("更改背景图片:"+user);
        return userService.changeBackground(user);
    }

    /**
     * 更改头像
     * @param user
     * @return
     */
    @PostMapping("/update/userimg")
    public Boolean updateUserImg(@RequestBody User user){
        System.out.println("更改头像:"+user);
        return userService.changeUserImg(user);
    }

    /**
     * 更改昵称
     * @param user
     * @return
     */
    @PostMapping("/update/username")
    public Boolean updateUserName(@RequestBody User user){
        System.out.println("更改昵称:"+user);
        return userService.changeUserName(user);
    }

    /**
     * 更改个性签名
     * @param user
     * @return
     */
    @PostMapping("/update/sign")
    public Boolean updateSign(@RequestBody User user){
        System.out.println("更改个性签名:"+user);
        return userService.changeSign(user);
    }


}
